A type that any function is assignable to.
Use as a generic constraint (T extends AnyFunction)
and for function parameters (a: AnyFunction).
Use (...args: unknown[]) => unknown instead for function return types.
<created by @somebody1234>
A function taking 0 arguments.
A function taking 1 argument.
A function taking 2 arguments.
Array of functions to compose/pipe with.
R.cond's [predicate, transform] pair.
R.cond's [predicate, transform] pair in a typeguarded version
a is equal to b
Represents all objects evolvable with Evolver E
A set of transformation to run as part of an evolve
the type to be evolved
All falsy JavaScript values representable by the type system.
A type representing any function. Useful as a generic constraint.
A functor satisfying the FantasyLand spec
a is greater than b
Checks if corresponding types of arguments in functions overlap(have at least one type in common, except never)
Returns unknown if arguments types overlap, else returns ErrorMsg
Type to check
<created by @valerii15298>
Converts an array of functions taking a single parameter to an array of their parameter types.
The array of functions
A pair containing the key and corresponding value of an object.
Key type
Value type
a is less than b
Given array of functions will return new array which will be constructed merging all functions parameters array using mergeArrays generic.
If provided array is not array of functions, return type will be empty array([])
Array of functions
<created by @valerii15298>
Type of the full object
Type of the lens focus
Merge an object O1 with O2
O1 & O2 are intersected with [] so that we can
handle the scenario where we merge arrays (like ramda).
Ramda removes array props when merging arrays, and thus
only keeps own properties. This is what ObjectOf does.
=> ramda's merge functions are 100% properly typed.
<created by @pirix-gh>
Merge multiple objects Os with each other
It essentially works like Merge, since the utility
MergeUp is used by AssignUp internally.
<created by @pirix-gh>
Predicate for an object containing the key.
An object with at least one of its properties beeing of type Key.
Values that can be compared using the relational operators </<=/>/>=
Represents two values' order
A placeholder used to skip parameters, instead adding a parameter to the returned function.
Takes a lists of arguments and returns either true or false.
Classical predicates only take one argument, but since ramda supports multiple arguments, we also use them like that.
Note that these predicates, don't represent typeguards, meaning when this type is used, we can't get type narrowing.
Takes an argument and returns either true or false.
This is usually used as an overload before Pred.
If you would this type alone, the function would required
to be a typeguard, meaning a simple function just returning
a boolean wouldn't satisfy this constrain.
Converts an array of functions to an array of their return types.
The array of functions
Take first N types of an Tuple
Length of prefix to take
Input tuple type
Map tuple of ordinary type to tuple of array type [string, number] -> [string[], number[]]
Map tuple of ordinary type to tuple of function type
Parameter type of every function
Return type of every function
A homogeneous tuple of length N.
Type of every element of the tuple
Length of the tuple
The type of the values of a record.
The record.
If T is a union, T[keyof T] (cf. map and values in index.d.ts) contains the types of object values that are common across the union (i.e., an intersection).
Because we want to include the types of all values, including those that occur in some, but not all members of the union, we first define ValueOfUnion.
The (possible) union
Merge second array with first one, resulting array will have the same length as array T1, every item in new array will be item from first array(T1) by corresponding index intersected with item from second array(also with the same index) if such exist
examples:
mergeArrWithLeft<[1, number, number, string], [number, 2, 7]> => [1, 2, 7, string]
mergeArrWithLeft<[1, string], [number, "exact text", number, any]> => [1, "exact text"]
<created by @valerii15298>
A special placeholder value used to specify "gaps" within curried functions, allowing partial application of any combination of arguments, regardless of their positions.
If g is a curried ternary function and _ is R.__, the following are equivalent:
g(1, 2, 3)g(_, 2, 3)(1)g(_, _, 3)(1)(2)g(_, _, 3)(1, 2)g(_, 2, _)(1, 3)g(_, 2)(1)(3)g(_, 2)(1, 3)g(_, 2)(_, 3)(1)A function that always returns false.
Any passed in parameters are ignored.
See also T.
A function that always returns true. Any passed in parameters are ignored.
See also F.
Adds two values. Equivalent to a + b but curried.
Creates a new list iteration function from an existing one by adding two new parameters to its callback function: the current index, and the entire list.
This would turn, for instance, R.map function into one that more closely resembles Array.prototype.map.
Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.
See also update.
Returns true if all elements of the list match the predicate, false if there are any that don't.
Takes a list of predicates and returns a predicate that returns true for a given list of arguments if every one of the provided predicates is satisfied by those arguments.
The function returned is a curried function whose arity matches that of the highest-arity predicate.
See also anyPass.
Takes a list of predicates and returns a predicate that returns true for a given list of arguments if every one of the provided predicates is satisfied by those arguments.
The function returned is a curried function whose arity matches that of the highest-arity predicate.
See also anyPass.
Returns a function that always returns the given value.
Returns a function that always returns the given value.
A function that returns the first argument if it's falsy otherwise the second argument.
Returns the result of applying the onSuccess function to the value inside a successfully resolved Promise.
This is useful for working with Promises inside function compositions.
See also otherwise.
Returns true if at least one of elements of the list match the predicate, false otherwise.
Takes a list of predicates and returns a predicate that returns true for a given list of arguments if at least one of the provided predicates is satisfied by those arguments.
The function returned is a curried function whose arity matches that of the highest-arity predicate.
See also allPass.
Takes a list of predicates and returns a predicate that returns true for a given list of arguments if at least one of the provided predicates is satisfied by those arguments.
The function returned is a curried function whose arity matches that of the highest-arity predicate.
See also allPass.
ap applies a list of functions to a list of values.
Dispatches to the ap method of the first argument, if present.
Also treats curried functions as applicatives.
Returns a new list, composed of n-tuples of consecutive elements.
If n is greater than the length of the list, an empty list is returned.
Acts as a transducer if a transformer is given in list position.
See also transduce.
Returns a new list containing the contents of the given list, followed by the given element.
See also prepend.
Applies function fn to the argument list args.
This is useful for creating a fixed-arity function from a variadic function.
fn should be a bound function if context is significant.
Given a spec object recursively mapping properties to functions, creates a function producing an object of the same structure, by mapping each property to the result of calling its associated function with the supplied arguments.
Given a spec object recursively mapping properties to functions, creates a function producing an object of the same structure, by mapping each property to the result of calling its associated function with the supplied arguments.
Takes a value and applies a function to it.
This function is also known as the thrush combinator.
Makes a shallow clone of an object, setting or overriding the specified property with the given value.
Makes a shallow clone of an object, setting or overriding the specified property with the given value.
Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and placing the specific value at the tail end of that path.
Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and placing the specific value at the tail end of that path.
Wraps a function of any arity (including nullary) in a function that accepts exactly 2 parameters. Any extraneous parameters will not be passed to the supplied function.
Wraps a function of any arity (including nullary) in a function that accepts exactly 2 parameters. Any extraneous parameters will not be passed to the supplied function.
Creates a function that is bound to a context.
Creates a function that is bound to a context.
A function which calls the two provided functions and returns the && of the
results. It returns the result of the first function if it is falsy and
the result of the second function otherwise.
A function which calls the two provided functions and returns the && of the
results. It returns the result of the first function if it is falsy and
the result of the second function otherwise.
Returns the result of calling its first argument with the remaining arguments.
This is occasionally useful as a converging function for R.converge:
the first branch can produce a function
while the remaining branches produce values to be passed to that function as its arguments.
See also apply.
chain maps a function over a list and concatenates the results. chain is also known as flatMap in some libraries.
Dispatches to the chain method of the second argument, if present, according to the FantasyLand Chain spec.
If second argument is a function, chain(f, g)(x) is equivalent to f(g(x), x).
Acts as a transducer if a transformer is given in list position.
See also transduce.
Restricts a number to be within a range.
Also works for other ordered types such as strings and Dates.
Creates a deep copy of the source that can be used in place of the source object without retaining any references to it.
The source object may contain (nested) Arrays and Objects, numbers, strings, booleans and Dates.
Functions are assigned by reference rather than copied.
Dispatches to a clone method if present.
Note that if the source object has multiple nodes that share a reference, the returned object will have the same structure, but the references will be pointed to the location within the cloned value.
Splits a list into sub-lists, based on the result of calling a key-returning function on each element, and grouping the results according to values returned.
Makes a comparator function out of a function that reports whether the first element is less than the second.
Makes a comparator function out of a function that reports whether the first element is less than the second.
Takes a function f and returns a function g such that
if called with the same arguments
when f returns a truthy value, g returns false
and when f returns a falsy value g returns true.
R.complement may be applied to any functor.
See also not.
Takes a function f and returns a function g such that
if called with the same arguments
when f returns a truthy value, g returns false
and when f returns a falsy value g returns true.
R.complement may be applied to any functor.
See also not.
Performs right-to-left function composition. The rightmost function may have any arity; the remaining functions must be unary.
Performs right-to-left function composition. The rightmost function may have any arity; the remaining functions must be unary.
Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings only support arrays for now. All functions must be unary. R.composeK(h, g, f) is equivalent to R.compose(R.chain(h), R.chain(g), f).
Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings only support arrays for now. All functions must be unary. R.composeK(h, g, f) is equivalent to R.compose(R.chain(h), R.chain(g), f).
Performs right-to-left composition of one or more Promise-returning functions. All functions must be unary.
Performs right-to-left composition of one or more Promise-returning functions. All functions must be unary.
Performs right-to-left function composition using transforming function. The last function may have any arity; the remaining functions must be unary.
Performs right-to-left function composition using transforming function. The last function may have any arity; the remaining functions must be unary.
Returns the result of concatenating the given lists or strings.
Returns a function, fn, which encapsulates if/else, if/else, ... logic.
R.cond takes a list of [predicate, transformer] pairs. All of the arguments
to fn are applied to each of the predicates in turn until one returns a
"truthy" value, at which point fn returns the result of applying its
arguments to the corresponding transformer. If none of the predicates
matches, fn returns undefined.
Returns a function, fn, which encapsulates if/else, if/else, ... logic.
R.cond takes a list of [predicate, transformer] pairs. All of the arguments
to fn are applied to each of the predicates in turn until one returns a
"truthy" value, at which point fn returns the result of applying its
arguments to the corresponding transformer. If none of the predicates
matches, fn returns undefined.
Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
See also invoker.
Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. The arity of the function returned is specified to allow using variadic constructor functions.
Returns true if the specified item is somewhere in the list, false otherwise.
Equivalent to indexOf(a)(list) > -1. Uses strict (===) equality checking.
Returns true if the specified item is somewhere in the list, false otherwise.
Equivalent to indexOf(a)(list) > -1. Uses strict (===) equality checking.
Accepts a converging function and a list of branching functions and returns a new function. When invoked, this new function is applied to some arguments, each branching function is applied to those same arguments. The results of each branching function are passed as arguments to the converging function to produce the return value.
See also useWith.
Returns the number of items in a given list matching the predicate f.
Counts the elements of a list according to how many match each value of a key generated by the supplied function.
Returns an object mapping the keys produced by fn to the number of occurrences in the list.
Note that all keys are coerced to strings because of how JavaScript objects work.
Acts as a transducer if a transformer is given in list position.
See also transduce.
Returns a curried equivalent of the provided function.
The curried function has two unusual capabilities.
First, its arguments needn't be provided one at a time.
If f is a ternary function and g is R.curry(f), the following are equivalent:
g(1)(2)(3)g(1)(2, 3)g(1, 2)(3)g(1, 2, 3)Secondly, the special placeholder value R.__ may be used to specify "gaps",
allowing partial application of any combination of arguments,
regardless of their positions.
If g is as above and _ is R.__, the following are equivalent:
g(1, 2, 3)g(_, 2, 3)(1)g(_, _, 3)(1)(2)g(_, _, 3)(1, 2)g(_, 2)(1)(3)g(_, 2)(1, 3)g(_, 2)(_, 3)(1)Returns a curried equivalent of the provided function, with the specified arity.
See also curry.
The curried function has two unusual capabilities.
First, its arguments needn't be provided one at a time.
If f is a ternary function and g is R.curry(f), the following are equivalent:
g(1)(2)(3)g(1)(2, 3)g(1, 2)(3)g(1, 2, 3)Secondly, the special placeholder value R.__ may be used to specify "gaps",
allowing partial application of any combination of arguments,
regardless of their positions.
If g is as above and _ is R.__, the following are equivalent:
g(1, 2, 3)g(_, 2, 3)(1)g(_, _, 3)(1)(2)g(_, _, 3)(1, 2)g(_, 2)(1)(3)g(_, 2)(1, 3)g(_, 2)(_, 3)(1)Decrements its argument.
See also inc.
Returns the second argument if it is not null, undefined or NaN; otherwise the first argument is returned.
Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
Objects and Arrays are compared in terms of value equality, not reference equality.
See also differenceWith, symmetricDifference, symmetricDifferenceWith, without.
Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
See also See also difference, symmetricDifference, symmetricDifferenceWith.
Divides two numbers. Equivalent to a / b but curried.
See also multiply.
Divides two numbers. Equivalent to a / b but curried.
See also multiply.
Returns all but the first n elements of the given list, string, or transducer/transformer.
Returns a list containing all but the last n elements of the given list.
Acts as a transducer if a transformer is given in list position.
See also takeLast, drop, dropWhile, dropLastWhile, transduce.
Returns a new list excluding all the tailing elements of a given list which satisfy the supplied predicate function. It passes each value from the right to the supplied predicate function, skipping elements until the predicate function returns a falsy value.
Acts as a transducer if a transformer is given in list position.
See also takeLastWhile, addIndex, drop, dropWhile, transduce.
Returns a new list without any consecutively repeating elements. Equality is determined by applying the supplied predicate to each pair of consecutive elements. The first element in a series of equal elements will be preserved.
Acts as a transducer if a transformer is given in list position.
See also transduce.
Returns a new list excluding the leading elements of a given list which satisfy the supplied predicate function. It passes each value to the supplied predicate function, skipping elements while the predicate function returns a truthy value.
A function wrapping calls to the two functions in an || operation,
returning the result of the first function if it is truthy
and the result of the second function otherwise.
Returns the empty value of its argument's type.
Ramda defines the empty value of Array ([]), Object ({}), string (''),
TypedArray (Uint8Array [], Float32Array [], etc) and arguments.
Other types are supported if they define <Type>.empty, <Type>.prototype.empty
or implement the FantasyLand Monoid spec.
Dispatches to the empty method of the first argument, if present.
Checks if a list ends with the provided sublist.
Similarly, checks if a string ends with the provided substring.
See also startsWith.
Takes a function and two values in its domain and returns true if the values map to the same value in the codomain;
false otherwise.
Reports whether two objects have the same value, in R.equals terms, for the specified property.
Useful as a curried predicate.
Returns true if its arguments are equivalent, false otherwise.
Handles cyclical data structures.
Dispatches symmetrically to the equals methods of both arguments, if present.
Returns true if its arguments are equivalent, false otherwise.
Handles cyclical data structures.
Dispatches symmetrically to the equals methods of both arguments, if present.
Creates a new object by evolving a shallow copy of the object,
according to the functions in transformations.
All non-primitive properties are copied by reference.
A function in transformations will not be invoked if its corresponding key does not exist in the evolved object.
Takes a predicate and a Filterable,
and returns a new Filterable of the same type
containing the members of the given Filterable which satisfy the given predicate.
Filterable objects include plain objects or any object that has a filter method such as Array.
Returns the first element of the list which matches the predicate,
or undefined if no element matches.
Dispatches to the find method of the second argument, if present.
Acts as a transducer if a transformer is given in list position.
See also transduce.
Returns the index of the first element of the list which matches the predicate,
or -1 if no element matches.
Returns the last element of the list which matches the predicate, or undefined if no element matches.
Acts as a transducer if a transformer is given in list position.
See also transduce.
Returns the index of the last element of the list which matches the predicate,
or -1 if no element matches.
Acts as a transducer if a transformer is given in list position.
See also lastIndexOf, transduce.
Returns a new list by pulling every item out of it (and all its sub-arrays) and putting them in a new array, depth-first.
See also unnest.
Flips the order of the first two arguments to the given function.
Flips the order of the first two arguments to the given function.
Iterate over the given list, calling the given function for each element in the list.
Iterate over the given object, calling the given function for each key and value in the object.
Creates a new object from a list key-value pairs. If a key appears in multiple pairs, the rightmost pair is included in the object.
Splits a list into sub-lists stored in an object, based on the result of calling a key-returning function on each element, and grouping the results according to values returned.
Takes a list and returns a list of lists where every adjacent element of each sublist satisfies the given predicate.
Takes a list and returns a list of lists where every adjacent element of each sublist satisfies the given predicate.
Returns true if the first parameter is greater than the second; false otherwise.
Returns true if the first parameter is greater than the second; false otherwise.
Returns true if the first parameter is greater than or equal to the second; false otherwise.
Returns true if the first parameter is greater than or equal to the second; false otherwise.
Returns whether or not an object has an own property with the specified name.
Returns whether or not an object has an own property with the specified name.
Returns whether or not an object or its prototype chain has a property with the specified name.
Returns whether or not a path exists in an object. Only the object's own properties are checked.
See also has.
Returns the first element in a list.
In some libraries this function is named first.
Returns true if its arguments are identical, false otherwise.
Values are identical if they reference the same memory.
NaN is identical to NaN; 0 and -0 are not identical.
A function that returns its argument. Good as a default or placeholder function.
Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.
Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.
Increments its argument.
See also dec.
Returns true if the specified value is equal, in R.equals terms,
to at least one element of the given list; false otherwise.
Also works with strings.
See also any.
Returns true if the specified value is equal, in R.equals terms,
to at least one element of the given list; false otherwise.
Also works with strings.
See also any.
Given a function that generates a key, turns a list of objects into an object indexing the objects by the given key.
Returns the position of the first occurrence of an item in an array,
or -1 if the item is not included in the array.
R.equals is used to determine equality.
See also lastIndexOf, findIndex.
Takes a predicate pred, a list xs, and a list ys,
and returns a list xs' comprising each of the elements of xs
which is equal to one or more elements of ys according to pred.
pred must be a binary function expecting an element from each list.
xs, ys, and xs' are treated as sets, semantically, so ordering should not be significant,
but since xs' is ordered the implementation guarantees
that its values are in the same order as they appear in xs.
Duplicates are not removed, so xs' may contain duplicates if xs contains duplicates.
See also intersection.
Returns a copy of the list with the element inserted at the index.
Returns a copy of the list with the elements inserted at the index.
Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.
See also innerJoin.
Creates a new list with the separator interposed between elements.
Dispatches to the intersperse method of the second argument, if present.
Transforms the items of the list with the transducer and appends the transformed items to the accumulator using an appropriate iterator function based on the accumulator type.
The accumulator can be an array, string, object or a transformer. Iterated items will be appended to arrays and concatenated to strings. Objects will be merged directly or 2-item tuples will be merged as key, value pairs.
The accumulator can also be a transformer object that provides:
R.identity.The iteration is performed with R.reduce after initializing the transducer.
See also transduce.
Same as R.invertObj,
however this accounts for objects with duplicate values by putting the values into an array.
See also invertObj.
Returns a new object with the keys of the given object as values, and the values of the given object as keys.
Turns a named method with a specified arity into a function that can be called directly supplied with arguments and a target object.
The returned function is curried and accepts arity + 1 parameters
where the final parameter is the target object.
Turns a named method with a specified arity into a function that can be called directly supplied with arguments and a target object.
The returned function is curried and accepts arity + 1 parameters
where the final parameter is the target object.
See if an object (val) is an instance of the supplied constructor.
This function will check up the inheritance chain, if any.
If val was created using Object.create, R.is(Object, val) === true.
See also propIs.
Returns true if the given value is its type's empty value; false otherwise.
See also empty.
Checks if the input value is null or undefined.
Returns a string made by inserting the given separator between each element and concatenating all the elements into a single string.
See also split.
Applies a list of functions to a list of values.
See also applySpec.
Applies a list of functions to a list of values.
See also applySpec.
Returns a list containing the names of all the enumerable own properties of the supplied object.
Returns a list containing the names of all the properties of the supplied object, including prototype properties.
Returns the position of the last occurrence of an item in an array,
or -1 if the item is not included in the array.
R.equals is used to determine equality.
See also indexOf, findLastIndex.
Returns the number of elements in the array by returning list.length.
Returns a lens for the given getter and setter functions. The getter "gets" the value of the focus; the setter "sets" the value of the focus. The setter should not mutate the data structure.
"lifts" a function of arity > 1 so that it may "map over" a list,
Function or other object that satisfies the FantasyLand Apply spec.
See also liftN.
"lifts" a function to be the specified arity, so that it may "map over" that many lists, Functions or other objects that satisfy the FantasyLand Apply spec.
Returns true if the first parameter is less than the second; false otherwise.
Returns true if the first parameter is less than the second; false otherwise.
Returns true if the first parameter is less than or equal to the second; false otherwise.
Returns true if the first parameter is less than or equal to the second; false otherwise.
Takes a function and a functor, applies the function to each of the functor's values, and returns a functor of the same shape.
Ramda provides suitable map implementations for Array and Object,
so this function may be applied to [1, 2, 3] or {x: 1, y: 2, z: 3}.
Dispatches to the map method of the second argument, if present.
Acts as a transducer if a transformer is given in list position.
Also treats functions as functors and will compose them together.
The mapAccum function behaves like a combination of map and reduce;
it applies a function to each element of a list,
passing an accumulating parameter from left to right,
and returning a final value of this accumulator together with the new list.
The iterator function receives two arguments, acc and value,
and should return a tuple [acc, value].
See also scan, addIndex, mapAccumRight.
Applies a function to each element of a list, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new list.
Tests a RegExp against a String.
mathMod behaves like the modulo operator should mathematically,
unlike the % operator (and by extension, R.modulo).
So while -17 % 5 is -2, mathMod(-17, 5) is 3.
mathMod requires integer arguments,
and returns NaN when the modulus is zero or negative.
See also modulo.
mathMod behaves like the modulo operator should mathematically,
unlike the % operator (and by extension, R.modulo).
So while -17 % 5 is -2, mathMod(-17, 5) is 3.
mathMod requires integer arguments,
and returns NaN when the modulus is zero or negative.
See also modulo.
Takes a function and two values, and returns whichever value produces the larger result when passed to the provided function.
Returns the mean of the given list of numbers.
See also median.
Returns the median of the given list of numbers.
See also mean.
Creates a new function that, when invoked, caches the result of calling the given function for a given argument set and returns the result. Subsequent calls to the memoized function with the same argument set will return the cached result.
Create a new object with the own properties of a merged with the own properties of object b. This function will not mutate passed-in objects.
Create a new object with the own properties of a merged with the own properties of object b. This function will not mutate passed-in objects.
Creates a new object with the own properties of the first object merged with the own properties of the second object.
If a key exists in both objects:
See also mergeDeepRight, mergeDeepWith, mergeDeepWithKey.
Creates a new object with the own properties of the first object merged with the own properties of the second object.
If a key exists in both objects:
See also mergeDeepLeft, mergeDeepWith, mergeDeepWithKey.
Creates a new object with the own properties of the two provided objects.
If a key exists in both objects:
See also mergeWith, mergeDeepWithKey.
Creates a new object with the own properties of the two provided objects. If a key exists in both objects: and both associated values are also objects then the values will be recursively merged. otherwise the provided function is applied to the key and associated values using the resulting value as the new value associated with the key. If a key only exists in one object, the value will be associated with the key of the resulting object.
See also mergeWith, mergeWithKey, mergeDeepWith.
Create a new object with the own properties of the first object merged with the own properties of the second object. If a key exists in both objects, the value from the first object will be used.
See also mergeRight, mergeDeepLeft, mergeWith, mergeWithKey.
Create a new object with the own properties of the first object merged with the own properties of the second object. If a key exists in both objects, the value from the second object will be used.
See also mergeLeft, mergeDeepRight, mergeWith, mergeWithKey.
Creates a new object with the own properties of the two provided objects.
If a key exists in both objects,
the provided function is applied to the values associated with the key in each object,
with the result being used as the value associated with the key in the returned object.
The key will be excluded from the returned object
if the resulting value is undefined.
See also mergeDeepWith, merge, mergeWithKey.
Creates a new object with the own properties of the two provided objects.
If a key exists in both objects,
the provided function is applied to the key and the values associated with the key in each object,
with the result being used as the value associated with the key in the returned object.
The key will be excluded from the returned object
if the resulting value is undefined.
See also mergeDeepWithKey, merge, mergeWith.
Takes a function and two values, and returns whichever value produces the smaller result when passed to the provided function.
Returns the modulo of two numbers. Equivalent to a % b but curried.
Divides the first parameter by the second and returns the remainder.
Note that this function preserves the JavaScript-style behavior for modulo.
For mathematical modulo see R.mathMod.
See also mathMod.
Returns the modulo of two numbers. Equivalent to a % b but curried.
Divides the first parameter by the second and returns the remainder.
Note that this function preserves the JavaScript-style behavior for modulo.
For mathematical modulo see R.mathMod.
See also mathMod.
Returns a copy of the given list with the item at the given source index moved to the given destination index.
Multiplies two numbers. Equivalent to a * b but curried.
See also divide.
Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. Any extraneous parameters will not be passed to the supplied function.
Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. Any extraneous parameters will not be passed to the supplied function.
Negates its argument.
Returns true if no elements of the list match the predicate, false otherwise.
A function that returns the ! of its argument.
It will return true when passed falsy value, and false when passed a truthy one.
See also complement.
Returns the nth element of the given list or string.
If n is negative the element at index length + n is returned.
Returns a function which returns its nth argument.
Returns a function which returns its nth argument.
o is a curried composition function that returns a unary function.
Like compose, o performs right-to-left function composition.
Unlike compose, the rightmost function passed to o will be invoked with only one argument.
Also, unlike compose, o is limited to accepting only 2 unary functions.
The name o was chosen because of its similarity to the mathematical composition operator ∘.
Creates an object containing a single key:value pair.
See also pair.
Returns a singleton array containing the value provided.
Returns a partial copy of an object omitting the keys specified.
See also pick.
Takes a binary function f, a unary function g, and two values.
Applies g to each value, then applies the result of each to f.
Also known as the P combinator.
Accepts a function fn and returns a function that guards invocation of fn
such that fn can only ever be called once,
no matter how many times the returned function is invoked.
The first value calculated is returned in subsequent invocations.
Returns the result of applying the onFailure function to the value inside a failed Promise.
This is useful for handling rejected Promises inside function compositions.
Returns the result of "setting" the portion of the given data structure focused by the given lens to the given value.
Takes a function f and a list of arguments, and returns a function g.
When applied, g returns the result of applying f to the arguments provided initially
followed by the arguments provided to g.
See also partialRight, curry.
Takes a function f and a list of arguments, and returns a function g.
When applied, g returns the result of applying f to the arguments provided initially
followed by the arguments provided to g.
See also partialRight, curry.
Takes a function f and an object, and returns a function g.
When applied, g returns the result of applying f to the object
provided initially merged deeply (right) with the object provided as an argument to g.
See also partial, partialRight, curry, mergeDeepRight.
Takes a function f and an object, and returns a function g.
When applied, g returns the result of applying f to the object
provided initially merged deeply (right) with the object provided as an argument to g.
See also partial, partialRight, curry, mergeDeepRight.
Takes a function f and a list of arguments, and returns a function g.
When applied, g returns the result of applying f to the arguments
provided to g followed by the arguments provided initially.
See also partial.
Takes a function f and a list of arguments, and returns a function g.
When applied, g returns the result of applying f to the arguments
provided to g followed by the arguments provided initially.
See also partial.
Takes a predicate and a list or other Filterable object
and returns the elements split into two lists
based on whether the element satisfied the predicate.
Filterable objects include plain objects
and objects with a filter method such as Array.
Determines whether a nested path on an object has a specific value,
in R.equals terms.
Most likely used to filter a list.
If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.
Returns true if the specified object property at given path satisfies the given predicate;
false otherwise.
See also propSatisfies, path.
Returns a partial copy of an object containing only the keys specified. If the key does not exist, the property is ignored.
Similar to pick except that this one includes a key: undefined pair for properties that don't exist.
Creates a new function that runs each of the functions supplied as parameters in turn, passing the return value of each function invocation to the next function invocation, beginning with whatever arguments were passed to the initial invocation.
Performs left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.
In some libraries this function is named sequence.
Creates a new function that runs each of the functions supplied as parameters in turn, passing the return value of each function invocation to the next function invocation, beginning with whatever arguments were passed to the initial invocation.
Performs left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.
In some libraries this function is named sequence.
Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings currently support arrays only as return values. All functions need to be unary. R.pipeK(f, g, h) is equivalent to R.pipe(f, R.chain(g), R.chain(h)).
Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings currently support arrays only as return values. All functions need to be unary. R.pipeK(f, g, h) is equivalent to R.pipe(f, R.chain(g), R.chain(h)).
Performs left-to-right composition of one or more Promise-returning functions. All functions need to be unary.
Performs left-to-right composition of one or more Promise-returning functions. All functions need to be unary.
Performs left-to-right function composition using transforming function. The first function may have any arity; the remaining functions must be unary.
Performs left-to-right function composition using transforming function. The first function may have any arity; the remaining functions must be unary.
Returns a new list by plucking the same named property off all objects in the list supplied.
Returns a new list with the given element at the front, followed by the contents of the list.
See also append.
Multiplies together all the elements of a list.
See also reduce.
Takes two functions as pre- and post- processors respectively for a third function,
i.e. promap(f, g, h)(x) === g(h(f(x))).
Dispatches to the promap method of the third argument, if present,
according to the FantasyLand Profunctor spec.
Acts as a transducer if a transformer is given in profunctor position.
See also transduce.
Takes two functions as pre- and post- processors respectively for a third function,
i.e. promap(f, g, h)(x) === g(h(f(x))).
Dispatches to the promap method of the third argument, if present,
according to the FantasyLand Profunctor spec.
Acts as a transducer if a transformer is given in profunctor position.
See also transduce.
Returns a function that when supplied an object returns the indicated property of that object, if it exists.
Returns a function that when supplied an object returns the indicated property of that object, if it exists.
Returns true if the specified object property is equal,
in R.equals terms, to the given value; false otherwise.
You can test multiple properties with R.whereEq.
See also whereEq, propSatisfies, equals.
Returns true if the specified object property is of the given type; false otherwise.
See also is, propSatisfies.
Return the specified property of the given non-null object
if the property is present and its value is not null, undefined or NaN.
Otherwise the first argument is returned.
See also prop.
Return the specified property of the given non-null object
if the property is present and its value is not null, undefined or NaN.
Otherwise the first argument is returned.
See also prop.
Returns true if the specified object property satisfies the given predicate; false otherwise.
You can test multiple properties with R.where.
Acts as multiple prop: array of keys in, array of values out. Preserves order.
Returns a list of numbers from from (inclusive) to to (exclusive).
In mathematical terms, range(a, b) is equivalent to the half-open interval [a, b).
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
The iterator function receives two values: (acc, value). It may use R.reduced to shortcut the iteration.
Groups the elements of the list
according to the result of calling the string-returning function keyFn on each element
and reduces the elements of each group to a single value via the reducer function valueFn.
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
Similar to R.reduce, except moves through the input list from the right to the left.
The iterator function receives two values: (value, acc),
reversed compared to that of R.reduce's iterator function.
reduceRight may use R.reduced to short circuit the iteration.
Like R.reduce, R.reduceWhile returns a single item by iterating through the list,
successively calling the iterator function.
R.reduceWhile also takes a predicate that is evaluated before each step.
If the predicate returns a falsy value,
it "short-circuits" the iteration and returns the current value of the accumulator.
Returns a value wrapped to indicate that it is the final value of the R.reduce and R.transduce functions.
The returned value should be considered a black box:
the internal structure is not guaranteed to be stable.
This optimization is available to the below functions:
R.reduceR.reduceWhileR.reduceByR.reduceRightR.transduceSee also reduce, reduceWhile, reduceBy, reduceRight, transduce.
The complement of R.filter.
Returns a copy of the given list with the given number of elements removed, starting at the given start index.
See also without.
Returns a fixed list of size n, containing a specified identical value.
See also times.
Replace a substring or regex match in a string with a replacement.
The first two parameters correspond to the parameters of String.prototype.replace,
so the second parameter can also be a function.
Returns a new list or string with the elements in reverse order.
Similar to R.reduce, but returns a list of successively reduced values from the left.
Returns the result of "setting" the portion of the given data structure focused by the given lens to the given value.
Returns the elements of the given list or string
from fromIndex (inclusive) to toIndex (exclusive).
Dispatches to the slice method of the third argument, if present.
Returns a copy of the list, sorted according to the comparator function, which should accept two values at a time and return:
Sorts the list according to a key generated by the supplied function.
Splits a string into an array of strings based on the given separator.
See also join.
Splits a string into an array of strings based on the given separator.
See also join.
Splits a given list or string at a given index.
Splits a collection into slices of the specified length.
Takes a list and a predicate and returns a pair of lists. The first list contains all elements before (but not including) the first element for which the predicate returns a truthy value. The second list contains the rest of the elements. It will be empty if no elements satisfy the predicate.
Splits an array into slices on every occurrence of a value.
Checks if a list starts with the provided sublist.
Similarly, checks if a string starts with the provided substring.
See also endsWith.
Subtracts two numbers. Equivalent to a - b but curried.
Subtracts two numbers. Equivalent to a - b but curried.
Adds together all the elements of a list.
See also reduce.
Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.
See also symmetricDifferenceWith, difference, differenceWith.
Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
Returns all but the first element of a list or string.
Returns the first (at most) n elements of the given list, string, or transducer/transformer.
Dispatches to the take method of the second argument, if present.
See also drop.
Returns a new list containing the last (at most) n elements of the given list.
See also dropLast.
Returns a new list containing the last elements of a given list, passing each value to the supplied predicate function and terminating when the predicate function returns a falsy value. Excludes the element that caused the predicate function to fail.
See also dropLastWhile, addIndex.
Returns a new list containing the first elements of a given list, passing each value to the supplied predicate function, and terminating when the predicate function returns a falsy value.
Runs the given function with the supplied object, then returns the object. Acts as a transducer if a transformer is given as second parameter.
Determines whether a given string matches a given regular expression.
See also match.
Creates a thunk out of a function. A thunk delays a calculation until its result is needed, providing lazy evaluation of arguments.
See also partial, partialRight.
Calls an input function n times,
returning an array containing the results of those function calls.
fn is passed one argument:
The current value of n,
which begins at 0 and is gradually incremented to n - 1.
See also repeat.
The lower case version of a string.
See also toUpper.
Converts an object into an array of key, value arrays. Only the object's own properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
Converts an object into an array of key, value arrays. The object's own properties and prototype properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
See also toPairs.=
Returns the string representation of the given value.
eval'ing the output should result in a value equivalent to the input value.
Many of the built-in toString methods do not satisfy this requirement.
If the given value is an Object with a toString method other than Object.prototype.toString,
that method is invoked with no arguments to produce the return value.
This means user-defined constructor functions can provide a suitable toString method.
The upper case version of a string.
See also toLower.
Initializes a transducer using supplied iterator function. Returns a single item by iterating through the list, successively calling the transformed iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
The iterator function receives two values: (acc, value).
It will be wrapped as a transformer to initialize the transducer.
A transformer can be passed directly in place of an iterator function.
In both cases, iteration may be stopped early with the R.reduced function.
A transducer is a function that accepts a transformer and returns a transformer and can be composed directly.
The accumulator can also be a transformer object that provides:
R.transduce.The iteration is performed with R.reduce after initializing the transducer.
Transposes the rows and columns of a 2D list.
When passed a list of n lists of length x,
returns a list of x lists of length n.
Maps an Applicative-returning function over a Traversable,
then uses R.sequence to transform the resulting Traversable of Applicative
into an Applicative of Traversable.
Dispatches to the traverse method of the third argument, if present.
See also {@link sequence}.
Removes (strips) whitespace from both ends of the string.
R.tryCatch takes two functions, a tryer and a catcher.
The returned function evaluates the tryer;
if it does not throw, it simply returns the result.
If the tryer does throw,
the returned function evaluates the catcher function and returns its result.
Gives a single-word string description of the (native) type of a value,
returning such answers as 'Object', 'Number', 'Array', or 'Null'.
Does not attempt to distinguish user Object types any further,
reporting them all as 'Object'.
Uses Object.prototype.toString internally for values other than null and undefined.
Takes a function fn, which takes a single array argument, and returns a function which:
In other words, R.unapply derives a variadic function from a function which takes an array.
R.unapply is the inverse of R.apply.
See also apply.
Takes a function fn, which takes a single array argument, and returns a function which:
In other words, R.unapply derives a variadic function from a function which takes an array.
R.unapply is the inverse of R.apply.
See also apply.
Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. Any extraneous parameters will not be passed to the supplied function.
Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. Any extraneous parameters will not be passed to the supplied function.
Returns a function of arity n from a (manually) curried function.
Returns a function of arity n from a (manually) curried function.
Builds a list from a seed value. Accepts an iterator function, which returns either a falsy value to stop iteration or an array of length 2 containing the value to add to the resulting list and the seed to be used in the next call to the iterator function.
Combines two lists into a set (i.e. no duplicates) composed of the elements of each list.
Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements. If an element exists in both lists, the first element from the first list will be used.
Returns a new list containing only one copy of each element in the original list.
Returns a new list containing only one copy of each element in the original list,
based upon the value returned by applying the supplied function to each list element.
Prefers the first item if the supplied function produces the same value on two items.
R.equals is used for comparison.
Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied predicate to two list elements. Prefers the first item if two items compare equal based on the predicate.
Acts as a transducer if a transformer is given in list position.
See also transduce.
Tests the final argument by passing it to the given predicate function.
If the predicate is not satisfied,
the function will return the result of calling the whenFalseFn function with the same argument.
If the predicate is satisfied, the argument is returned as is.
Shorthand for R.chain(R.identity),
which removes one level of nesting from any Chain.
Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as the initial value. It does so by applying the transformation until the predicate is satisfied, at which point it returns the satisfactory value.
Returns a new copy of the array with the element at the provided index replaced with the given value.
See also adjust.
Accepts a function fn and a list of transformer functions and returns a new curried function. When the new function is invoked, it calls the function fn with parameters consisting of the result of calling each supplied handler on successive arguments to the new function.
If more arguments are passed to the returned function than transformer functions, those arguments are passed directly to fn as additional parameters. If you expect additional arguments that don't need to be transformed, although you can ignore them, it's best to pass an identity function so that the new function reports the correct arity.
See also converge.
Accepts a function fn and a list of transformer functions and returns a new curried function. When the new function is invoked, it calls the function fn with parameters consisting of the result of calling each supplied handler on successive arguments to the new function.
If more arguments are passed to the returned function than transformer functions, those arguments are passed directly to fn as additional parameters. If you expect additional arguments that don't need to be transformed, although you can ignore them, it's best to pass an identity function so that the new function reports the correct arity.
See also converge.
Returns a list of all the enumerable own properties of the supplied object.
Returns a list of all the properties, including prototype properties, of the supplied object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which portion of the data structure is visible.
Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which portion of the data structure is visible.
Tests the final argument by passing it to the given predicate function.
If the predicate is satisfied,
the function will return the result of calling the whenTrueFn function with the same argument.
If the predicate is not satisfied, the argument is returned as is.
Takes a spec object and a test object and returns true if the test satisfies the spec. Any property on the spec that is not a function is interpreted as an equality relation.
If the spec has a property mapped to a function,
then where evaluates the function,
passing in the test object's value for the property in question,
as well as the whole test object.
R.where is well suited to declaratively expressing constraints for other functions,
e.g., R.filter, R.find, R.pickWith, etc.
Seee also propSatisfies, whereEq.
Takes a spec object and a test object; returns true if the test satisfies the spec, false otherwise.
An object satisfies the spec if, for each of the spec's own properties,
accessing that property of the object gives the same value (in R.eq terms)
as accessing that property of the spec.
Returns a new list without values in the first argument.
R.equals is used to determine equality.
Acts as a transducer if a transformer is given in list position.
See also transduce, difference, remove.
Exclusive disjunction logical operation.
Returns true if one of the arguments is truthy and the other is falsy.
Otherwise, it returns false.
Creates a new list out of the two supplied by creating each possible pair from the lists
Short for cross product.
Creates a new list out of the two supplied by pairing up equally-positioned items from both lists. The returned list is truncated to the length of the shorter of the two input lists.
Creates a new object out of a list of keys and a list of values. Key/value pairing is truncated to the length of the shorter of the two lists.
Creates a new list out of the two supplied by applying the function to each equally-positioned pair in the lists.
Generated using TypeDoc
A type that any constructor is assignable to. Use as a generic constraint (
T extends AnyConstructor) and for function parameters (a: AnyConstructor). Usenew (...args: unknown[]) => unknowninstead for function return types.<created by @somebody1234>